package com.woniu.houtai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.houtai.entity.Product;
import com.woniu.houtai.mapper.ProductMapper;
import com.woniu.houtai.service.ProductService;
import com.woniu.houtai.utils.CookieUtils;
import com.woniu.houtai.utils.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author firstGroup
 * @since 2023-02-22 09:45:58
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
    @Autowired
    ProductMapper productMapper;

    @Override
    public int insertProductInfo(Product products) {
        int insert = productMapper.insert(products);

        return insert;
    }

    @Override
    public Page<Product> selectProduct(Integer currentPage,Integer pageSize,Integer shopId) {
        Page<Product> productPage = new Page<>(currentPage,pageSize);
        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("shop_id",shopId);
        Page<Product> productPageById = productMapper.selectPage(productPage,queryWrapper);
        return productPageById;
    }


    @Override
    public Product selectProductByPid(Integer productId) {
        return productMapper.selectById(productId);
    }
}
